<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	
    <link href="../../../NCProjectWeb/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" href="../../../NCProjectWeb/css/bootstrap-datetimepicker.min.css">
	
	<title>New Country</title>
</head>
<body>
	<%@ page import="entities.*" %>
	<%@ page import="java.util.ArrayList" %>
	<%@ page import = "java.util.Map" %>
	
	 <%
		Map<String, String> map = (Map<String, String>) request.getAttribute("map");
		
		String action = (String) request.getAttribute("action");	
		String formAction;
		if (action.equals("create")) {
			formAction = "createCountry";
		} else {
			formAction= "editCountry";
		} 
	%>		
	<form class="form-horizontal" method="Get" action="/NCProjectWeb/<%=formAction%>">
		<% if (action.equals("edit")) { 
			String id = (String) request.getAttribute("id");%>
			<input type="hidden" name="id" value="<%=id%>">
		<% } %>
			<div class="controls" style="text-align: center;">
				<h3>Создание новой страны</h3>
				<h5>Исправьте ошибки</h5>
			</div>
			<% if (map.get("countryname") != null)  { %>
				<div class="form-group has-error">
					<label class="col-sm-2 control-label" for="inputError">Страна</label> 
					<div class="col-sm-5">
						<input type="text" class="form-control" id="inputError" name="countryname" value="<%=request.getAttribute("countryname")%>">
					</div>
					<div class="col-sm-5">
						<label class="control-label" for="inputError"><%= map.get("countryname").toString() %></label> 
					</div>
				</div>
			<% } else {%>
				<div class="form-group">
					<label class="col-sm-2 control-label">Страна</label> 
					<div class="col-sm-5">
						<% if (action.equals("edit")) {%>
							<input type="text" class="form-control" name="countrynameDISABLED" value="<%=request.getAttribute("countryname")%>" disabled>
							<input type="hidden" name="countryname" value="<%=request.getAttribute("countryname")%>">
						<% } else {%>
							<input type="text" class="form-control" name="countryname" value="<%=request.getAttribute("countryname")%>">
						<% } %>
					</div>
				</div>
			<% } %>
			<% if (map.get("countrycode") != null)  { %>
				<div class="form-group has-error">
					<label class="col-sm-2 control-label" for="inputError">Код страны</label> 
					<div class="col-sm-5">
						<input type="text" class="form-control" id="inputError" name="countrycode" value="<%=request.getAttribute("countrycode")%>">
					</div>
					<div class="col-sm-5">
						<label class="control-label" for="inputError"><%= map.get("countrycode").toString() %></label> 
					</div>
				</div>
			<% } else {%>
				<div class="form-group">
					<label class="col-sm-2 control-label">Код страны</label> 
					<div class="col-sm-5">
						<% if (action.equals("edit")) {%>
							<input type="text" class="form-control" name="countrycodeDISABLED" value="<%=request.getAttribute("countrycode")%>" disabled>
							<input type="hidden" name="countrycode" value="<%=request.getAttribute("countrycode")%>">
						<% } else {%>
							<input type="text" class="form-control" name="countrycode" value="<%=request.getAttribute("countrycode")%>">
						<% } %>
					</div>
				</div>
			<% } %>
			
		<div class="form-group">
			<div class="col-sm-3"></div>
			<input type="submit" class="btn btn-default" value="Edit">
			<a class="btn btn-default" href="${pageContext.request.contextPath}/admin/index.jsp" role="button">Home</a>
		</div>
	</form>
</body>
</html>